Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SET commands #673

Merged
merged 1 commit into from
Nov 4, 2022
Merged

SET commands #673

merged 1 commit into from
Nov 4, 2022

Conversation

barakalon
Copy link
Collaborator

MySQL SET commands.

This also adds MySQL's session parameters: @@

@barakalon barakalon merged commit 855799c into main Nov 4, 2022
@barakalon barakalon deleted the barak/set-commands branch November 4, 2022 22:51
@mpf82
Copy link
Contributor

mpf82 commented Nov 7, 2022

SET used to be parsed as a "command", correct? and as such, you could basically write anything following it.

This PR breaks parsing valid SET statements, e.g.

Postgres:

SET application_name TO "app_admin"
SET SESSION application_name TO "app_admin"
SET LOCAL application_name = "app_admin"

Syntax:

SET [ SESSION | LOCAL ] configuration_parameter { TO | = } { value | 'value' | DEFAULT }
SET [ SESSION | LOCAL ] TIME ZONE { value | 'value' | LOCAL | DEFAULT }

Reference: https://www.postgresql.org/docs/current/sql-set.html


TSQL in general:

SET QUOTED_IDENTIFIER ON
SET QUOTED_IDENTIFIER, ANSI_NULLS ON

Reference: https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql?view=sql-server-ver16#considerations-when-you-use-the-set-statements

@barakalon
Copy link
Collaborator Author

That's correct - this will break parsing of SET in many dialects. This PR also opens the door for actually parsing SET in those dialects.

Two options:

  1. Implement SET parsing in Postgres, TSQL, etc
  2. Make the base Tokenizer/Parser keep SET as a Command, and only switch it to a Statement in dialects that have parsing implemented

@tobymao
Copy link
Owner

tobymao commented Nov 7, 2022

can you implement #2 for now?

@barakalon
Copy link
Collaborator Author

I'll be out all day today and did this in a rush:
#676

Feel free to take over/merge.

@tobymao
Copy link
Owner

tobymao commented Nov 7, 2022

ok i'll take over thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants